function copyText(text) {
  return new Promise((resolve, reject) => {
    const target = document.createElement("input");
    target.value = text;
    document.body.appendChild(target);
    target.select();
    try {
      document.execCommand("Copy");
      document.body.removeChild(target);
      resolve(true);
    } catch {
      reject(false);
    }
  });
}
